package reviewAlgorithms.dynamicProgramming;

public class DynamicProgramming {
    public static void main(String[] args) {
        int amount = 5;
        int[] cions = {1,2,5};
        System.out.println(change(amount,cions));
    }

    public static int change(int amount, int[] coins) {
        if (coins == null || coins.length < 1) {
            return 0;
        }
        if (amount < 1) {
            return 0;
        }
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                dp[i] += dp[i - coin];
            }
        }
        return dp[amount];
    }
}


